package com.example.demo

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import com.example.demo.utils.LocalManageUtil

class MainActivity : BaseActivity() {
    lateinit var tvSystemLanguage: TextView
    lateinit var tvUserSelectLanguage: TextView
    lateinit var tvValue: TextView
    lateinit var tvValue2: TextView

    lateinit var startNewActivity: Button
    lateinit var startNewIntentService: Button
    lateinit var startSettingActivity: Button
    lateinit var startNewService: Button

    companion object {
        fun restart(context: Context) {
            val intent = Intent(context, MainActivity::class.java)
            intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
            context.startActivity(intent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initView()
        setValue()
    }

    private fun initView() {
        // bind view
        tvSystemLanguage = findViewById(R.id.tv_system_language)
        tvUserSelectLanguage = findViewById(R.id.tv_user_select)
        tvValue = findViewById(R.id.tv_3)
        tvValue2 = findViewById(R.id.tv_4)

        startSettingActivity = findViewById(R.id.btn_3)

        startSettingActivity.setOnClickListener {
            SettingActivity.enter(this)
        }
    }

    private fun setValue() {
        tvSystemLanguage.text = getString(
            R.string.system_language,
            LocalManageUtil.getSystemLocale(this).displayLanguage
        )

        tvUserSelectLanguage.text = getString(
            R.string.user_select_language,
            LocalManageUtil.getSelectLanguage(this)
        )

        tvValue.text = getString(R.string.tv3_value)
        tvValue2.text = getString(R.string.tv3_value)
    }

}